﻿using CRM.Admin.Contracts.Contract.Customer;
using KingsSharp.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CRM.Admin.Contracts.Model.Customer;
using KingsSharp.Core.Data;
using KingsSharp.Common.Data;
using CRM.Admin.Contracts.Dto.Customer;
using KingsSharp.Common;

namespace CRM.Admin.Services.Service.Customer
{
    public class ServeMgService : ServiceBase, IServeMgService
    {
        private IRepository<ServeMg, Guid> ServeMgRepository;

        public ServeMgService(IRepository<ServeMg, Guid> _ServeMgRepository)
            :base(_ServeMgRepository.UnitOfWork)
        {
            ServeMgRepository = _ServeMgRepository;
        }

        public IQueryable<ServeMg> Item
        {
            get
            {
                return ServeMgRepository.Entities;
            }
        }

        public OperationResult Insert(params ServeMgDto[] dtos)
        {
            dtos.CheckNotNull("dtos");
            var result = ServeMgRepository.Insert(dtos);
            return result;
        }

        public OperationResult Update(params ServeMgDto[] dtos)
        {
            dtos.CheckNotNull("dtos");
            var result = ServeMgRepository.Update(dtos);
            return result;
        }

        public OperationResult Delete(params Guid[] ids)
        {
            ids.CheckNotNull("dtos");
            int delcount = ServeMgRepository.Delete(a => ids.Contains(a.Id));
            return new OperationResult(OperationResultType.Success, "删除成功");
        }

    }
}
